home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / checkbox / patches / 0.4 < prev    next >
Text File  |  2009-11-05  |  1KB  |  49 lines

  1. #!/usr/bin/python
  2.  
  3. import re
  4. import sys
  5.  
  6. from StringIO import StringIO
  7.  
  8.  
  9. def Config(filename):
  10.     globals = {}
  11.     module = "/usr/share/checkbox/install/config"
  12.     exec open(module) in globals
  13.     config = globals["Config"]()
  14.     config.read(filename)
  15.  
  16.     return config
  17.  
  18. def main(args):
  19.     config_file = "/etc/checkbox.d/%s.ini" % args[0]
  20.     config = Config(config_file)
  21.  
  22.     for section_name in config.sections():
  23.         if section_name in ["checkbox/plugins",
  24.                 "checkbox/registries",
  25.                 "checkbox/plugins/user_interface"]:
  26.             # Remove persist_filename option
  27.             option = "persist_filename"
  28.             if config.has_option(section_name, option):
  29.                 config.remove_option(section_name, option)
  30.         else:
  31.             # Remove everything else
  32.             config.remove_section(section_name)
  33.  
  34.     # Rename options
  35.     file = StringIO()
  36.     config.write(file)
  37.  
  38.     file.seek(0)
  39.     buffer = file.read()
  40.     buffer = re.sub(r"directories = ", "modules = ", buffer)
  41.     buffer = re.sub(r"gtk_path = ", "data_path = ", buffer)
  42.  
  43.     file = open(config_file, "w")
  44.     file.write(buffer)
  45.  
  46.  
  47. if __name__ == "__main__":
  48.     main(sys.argv[1:])
  49.